home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Code Samples / hotspots / nm8butn.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  1.7 KB  |  72 lines  |  [TEXT/ttxt]

  1. in module DemoModule
  2.  
  3. --*******************************************************************************
  4. --*        Class name:    AnimatedButton
  5. --*                                            
  6. --*     Inherits from: Animation, Button and Rollover                                    
  7. --*        Class type: Concrete
  8. --*         Component: User Interface
  9. --*
  10. --*       Description: This class is an example of how to mix in the Button class
  11. --*                    the Rollover class with an animation to produce a button that
  12. --*                    animates when the mouse enters or leaves its boundary.
  13. --*
  14. --*             Usage: ab := new AnimatedButton series:<a series of bitmaps> \
  15. --*                                             pressedBitmap:<some bitmap> 
  16. --*                    
  17. --*               IVs:        
  18. --*
  19. --*           Methods:    setPressedAppearance
  20. --*                    setReleasedAppearance
  21. --*                    
  22. --*    Required files:    animate.sx
  23. --*                    button.sx
  24. --*                    rollover.sx
  25. --*                    
  26. --*             Notes: 
  27. --*
  28. --*            Author:    Su Quek - Kaleida Labs, Inc.
  29. --*******************************************************************************
  30. class AnimatedButton (Animation, Button, Rollover)
  31. end
  32.  
  33. -- The following methods are specialized to handle the animation with the
  34. -- the button functionality.
  35. -- In this example, when the button is pressed, a red stroke appears around 
  36. -- the bitmap.
  37.  
  38. method setReleasedAppearance self {class AnimatedButton} -> 
  39. (
  40.     nextmethod self
  41.     self.boundary := self.series[self.cell]
  42.     self.stroke := undefined
  43. )
  44.     
  45. method setPressedAppearance self {class AnimatedButton} -> 
  46. (
  47.     nextmethod self
  48.     self.stroke := (new Brush color:redColor)
  49. )
  50.  
  51. method press self {class AnimatedButton} -> 
  52. (
  53.     nextmethod self
  54.     stop self
  55. )
  56.  
  57. method init self {class AnimatedButton} #rest args ->
  58. (
  59.     apply nextmethod self args
  60.     
  61.     self.enterAction := start
  62.     self.exitAction := stop
  63.     self.authordata := self
  64.  
  65.     self
  66. )
  67.  
  68.  
  69.  
  70.  
  71.  
  72.